package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domain.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {
    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE TYPE=#{type} AND log_time=#{today}")
    Integer queryByTypeAndLogTime(@Param("type") String type, @Param("today") String today);

    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE log_time=#{today}")
    Integer queryByLogTime(String today);

    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE log_time=#{today} AND user_id IN (SELECT user_id FROM tb_log WHERE TYPE='0102' AND log_time=#{yesterday})")
    Integer queryNumRetention1d(@Param("today") String today, @Param("yesterday") String yesterday);

    @Select("SELECT COUNT(user_id) FROM tb_log WHERE TYPE=#{type} AND log_time=#{today}")
    Integer queryNumLogin(@Param("type") String type, @Param("today") String today);
}
